package labox.innovation.gameserver.model.actor.knownlist;

import labox.innovation.config.Config;
import labox.innovation.gameserver.model.L2Object;
import labox.innovation.gameserver.model.actor.L2Npc;
import labox.innovation.gameserver.model.actor.instance.FuzePcInstance;
import labox.innovation.gameserver.network.serverpackets.DeleteObject;
import labox.innovation.gameserver.network.serverpackets.SpawnItem;

public class PcKnownList extends PlayableKnownList {
	// =========================================================
	// Data Field

	// =========================================================
	// Constructor
	public PcKnownList(FuzePcInstance activeChar) {
		super(activeChar);
	}

	@Override
	public boolean addKnownObject(L2Object object) {
		if (!super.addKnownObject(object))
			return false;
		if (object.getPoly().isMorphed() && object.getPoly().getPolyType().equals("item")) {//如果是一个道具
			getActiveChar().sendPacket(new SpawnItem(object));
		} else {
			object.sendInfo(getActiveChar());//把角色信息发出去
		}
		return true;
	}

	/**
	 * Remove a L2Object from L2PcInstance _knownObjects and _knownPlayer (if necessary) and send Server-Client Packet DeleteObject to the L2PcInstance.<BR>
	 * <BR>
	 * 
	 * @param object
	 *            The L2Object to remove from _knownObjects and _knownPlayer
	 * 
	 */
	@Override
	public boolean removeKnownObject(L2Object object) {
		if (!super.removeKnownObject(object))
			return false;
		// Send Server-Client Packet DeleteObject to the FuzePcInstance
		FuzePcInstance player = getActiveChar();
		//如果不是场景跳转状态删除对象，场景跳转不删除对象，由客户端直接删除
		if (!player.isTeleporting())
			player.sendPacket(new DeleteObject(object));
		if (Config.CHECK_KNOWN && object instanceof L2Npc)
			player.sendMessage("Removed NPC: " + ((L2Npc) object).getName());
		return true;
	}

	// =========================================================
	// Method - Private

	// =========================================================
	// Property - Public
	@Override
	public final FuzePcInstance getActiveChar() {
		return (FuzePcInstance) _activeObject;
	}

	@Override
	public int getDistanceToForgetObject(L2Object object) {
		return 60;
	}

	@Override
	public int getDistanceToWatchObject(L2Object object) {
		return 50; // Siege, TOI, city
	}
}
